$(document).ready(function(e) {
    $('#slider-content').anythingSlider({
		buildNavigation: false,
		buildStartStop: false,
		startPanel: 1,
		infiniteSlides:false,
		autoPlay:false,
		hashTags: false,
		expand: true
	});
	$(".slider-nav-a").click(function(){
    var slide = $(this).attr('href').substring(1);
    $('#slider-content').anythingSlider(slide);
	
    return false;
	});
	$(".slider-nav").click(function(){
    var slide = $(this).children('a').attr('href').substring(1);
    $('#slider-content').anythingSlider(slide);
    return false;
	});
	
// Guestbook sumbit
/* This flag will prevent multiple comment submits: */
	var working = false;
	
	/* Listening for the submit event of the form: */
	$('#addCommentForm').submit(function(e){

 		e.preventDefault();
		if(working) return false;
		
		working = true;
		$('#submit').val('Working..');
		$('span.error').remove();
		
		/* Sending the form fileds to submit.php: */
		$.post('guestbook/submit.php',$(this).serialize(),function(msg){

			working = false;
			$('#submit').val('Submit');
			
			if(msg.status){

				/* 
				/	If the insert was successful, add the comment
				/	below the last one on the page with a slideDown effect
				/*/

				$(msg.html).hide().insertBefore('.insetcommenthere').slideDown();
//				$('#comment-wrapp').append(msg.html).slideDown();
				$('#body').val('');
			}
			else {

				/*
				/	If there were errors, loop through the
				/	msg.errors object and display them on the page 
				/*/
				
				$.each(msg.errors,function(k,v){
					$('label[for='+k+']').append('<span class="error">'+v+'</span>');
				});
			}
		},'json');

	});
	
	
});

$('#slider-content').bind('slide_complete', function(event, slider){ 
if(slider.currentPage == 4) {
	$fp_galleries.click();
}


$(function() {      
      //Enable swiping...
	   $(".thumb").swipe({
        //Generic swipe handler for all directions
		 tap:function(event, target) {
          this.click();
        },
  excludedElements:[]
      });
      $("#fp_thumbScroller").swipe({
        //Generic swipe handler for all directions
		
        swipe:function(event, direction, distance, duration, fingerCount) {
         if(direction == 'left') {
			 $("#fp_next_thumb").click();
		 } else if (direction == 'right') {
			 $("#fp_prev_thumb").click();
		 }
        },
        //Default is 75px, set to 0 for demo so any distance triggers swipe
         threshold:0,
  excludedElements:[]
      });
	   $("#fp_overlay").swipe({
        //Generic swipe handler for all directions
		
        swipe:function(event, direction, distance, duration, fingerCount) {
         if(direction == 'left') {
			 $("#fp_next").click();
		 } else if (direction == 'right') {
			 $("#fp_prev").click();
		 }
        },
              treshold:0,   
  excludedElements:[]
      });
	 
	  
	  
	     
    });

 });
